const os = require('os');

const getIPAdress = () => {
  let interfaces = os.networkInterfaces();
  for (let devName in interfaces) {
    let iface: any = interfaces[devName];
    // tslint:disable-next-line:prefer-for-of
    for (let i = 0; i < iface.length; i++) {
      let alias = iface[i];
      if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
        return alias.address;
      }
    }
  }
}
module.exports = {
  getIP() {
    return getIPAdress()
  }
}
